﻿using System;
using System.Collections.Generic;
using FacebookWrapper.ObjectModel;

namespace Desktop_Facebook
{
	internal class MessageFilterer
	{
		public List<Message> FilterByPredicate(Predicate<Message> i_Predicate)
		{
			List<FacebookWrapper.ObjectModel.Message> filtered = new List<FacebookWrapper.ObjectModel.Message>();
			
			if (i_Predicate != null)
			{
				foreach (InboxThread currentThread in Session.Instance.LoggedInUser.InboxThreads)
				{
					foreach (Message currentMessasge in currentThread.Messages)
					{
						if (i_Predicate.Invoke(currentMessasge))
						{
							filtered.Add(currentMessasge);
						}
					}
				}
			}

			return filtered;			
		}
	}
}
